document.querySelectorAll('.faq-question').forEach(function (btn) { btn.addEventListener('click', function () { var answer = btn.nextElementSibling; var isOpen = btn.getAttribute('aria-expanded') === 'true'; if (isOpen) { btn.setAttribute('aria-expanded', 'false'); answer.style.maxHeight = '0px'; } else { btn.setAttribute('aria-expanded', 'true'); answer.style.maxHeight = answer.firstElementChild.scrollHeight + 'px'; } }); });